//
//  XCBaseTableViewController.swift
//  小陈微博Swift用纯代码创建
//
//  Created by 小陈 on 16/2/26.
//  Copyright © 2016年 小陈. All rights reserved.
//

import UIKit

class XCBaseTableViewController: UITableViewController,VisitorLoginViewDelegate{
 // 用户是否登记
    var userlogn = XCUSerAccountViewModel.sharedInstance.isUserLogin
    // 访问登录视图
    var visitorlongin : XCVisitorView?
    
  
    override func loadView() {
        if (userlogn ){
        super.loadView()
        return
        }
        
        visitorlongin = NSBundle.mainBundle().loadNibNamed("XCVisitorView", owner: nil, options: nil).last as? XCVisitorView
        /// 指定访问视图的代理对象
        visitorlongin?.vistorViewDelegate = self;
        
       view = visitorlongin
        
    navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "didSelectResgisterButton")
    navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "didSelectedLonginButton")
        
         setupVisitor()
    }
    
    
    func setupVisitor() {
        if self is XCHomeTableViewController {
            
            visitorlongin?.setUpInfo("visitordiscover_feed_image_house", message: "关注一些人，回这里看看有什么惊喜惊喜", isHome: true)
        }else if  self is XCMessageTableViewController {
            
            visitorlongin?.setUpInfo("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        }else if   self is XCdiscoverTableViewController{
            
            visitorlongin?.setUpInfo("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        }else if   self is XCprofileTableViewController{
            
            visitorlongin?.setUpInfo("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
    }
    // MARK: 实现按钮的点击事件
    func didSelectResgisterButton(){
        print("\(__FUNCTION__)")
        print("注册按钮")
        let networkingTool = XCNetworkingTool.sharedInstance
        print("networkingTool:\(networkingTool)")
    }
    func didSelectedLonginButton(){
        print("\(__FUNCTION__)")
        
        let oauthVC = XCOauthViewController()

     presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
        
        print("登录按钮")
    }
}


//
//extension XCBaseTableViewController: VisitorLoginViewDelegate {
//
//}



